<?php
namespace app\admin\model\steward;
use app\admin\model\user\User;
use app\common\traits\ModelCurd;
use think\Model;

class Apps extends Model
{
    use ModelCurd;
    protected $autoWriteTimestamp = true;
    protected $table = 'cp_apps';
    protected $json = ['app_photos'];
    protected $jsonAssoc = true;

    public function getAppPhotoAttr($value,$data)
    {
        return _get_image_preview_url($value);
    }

    public function category()
    {
        return $this->belongsToMany(Category::class,'apps_category_app','category_id','post_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class,"user_id");
    }

}